package com.ruisi.operateClasses;


import java.util.HashMap;
import java.util.List;

import com.ruisi.weatherreport.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class gridviewAdapter extends BaseAdapter{
	
	private List<HashMap<String,String>> list;
	private Context context;
	
	public gridviewAdapter(Context context,List<HashMap<String,String>> list){
	   this.list=list;
	   this.context=context;
	}
	
	@Override
	public int getCount(){
		return list.size();
	}
	
	@Override
	public Object getItem(int position){
		return list.get(position);
	}
	
	@Override
	public long getItemId(int position){
		return position;
	}
	
	public View getView(int position,View convertView,ViewGroup parent){
		Viewholder mholder;
		if(convertView==null){
			convertView=LayoutInflater.from(context).inflate(R.layout.grid_weatheritem, null);
			mholder=new Viewholder();
			mholder.img=(ImageView)convertView.findViewById(R.id.img_weather);
			mholder.text_date=(TextView)convertView.findViewById(R.id.tv_date);
			mholder.text_temp=(TextView)convertView.findViewById(R.id.tv_temp);
			convertView.setTag(mholder);
		}else{
			mholder=(Viewholder)convertView.getTag();
		}
		//mholder.img.setBackgroundDrawable(R.drawable.ic_launcher);
		mholder.text_date.setText((String)list.get(position).get("Date"));
		mholder.text_temp.setText((String)list.get(position).get("temp"));
		
		return convertView;
		
	}

}

class Viewholder{
	ImageView img;
	TextView text_temp;
	TextView text_date;
}
